package com.mdinic.blogovi.front;

import org.apache.wicket.Session;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.Response;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;

import com.mdinic.blogovi.front.page.BSession;
import com.mdinic.blogovi.front.page.HomePage;
import com.mdinic.blogovi.front.page.addblogpost.AddBlogPostPage;
import com.mdinic.blogovi.front.page.blogpost.BlogPostListByBlogPage;
import com.mdinic.blogovi.front.page.blogpost.BlogPostListPage;
import com.mdinic.blogovi.front.page.blogpost.BlogPostViewPage;
import com.mdinic.blogovi.front.page.blogpost.NewLinksPage;
import com.mdinic.blogovi.front.page.emailchange.EmailConfirmPage;
import com.mdinic.blogovi.front.page.faved.BlogPostFavsPage;
import com.mdinic.blogovi.front.page.follow.FollowLinksPage;
import com.mdinic.blogovi.front.page.forgotpass.ForgotPasswordPage;
import com.mdinic.blogovi.front.page.forgotpass.PasswordSentPage;
import com.mdinic.blogovi.front.page.person.PersonEditPage;
import com.mdinic.blogovi.front.page.person.PersonTopPage;
import com.mdinic.blogovi.front.page.person.PersonViewPage;
import com.mdinic.blogovi.front.page.person.picture.ChopPhotoPage;
import com.mdinic.blogovi.front.page.person.picture.UploadPhotoPage;
import com.mdinic.blogovi.front.page.register.RegisterConfirmPage;
import com.mdinic.blogovi.front.page.register.RegisterMailSentPage;
import com.mdinic.blogovi.front.page.register.RegisterPage;
import com.mdinic.blogovi.front.page.shared.BlogPostSharedPage;
import com.mdinic.blogovi.front.page.waitforapproval.BlogPostListNotApprovedPage;
import com.mdinic.blogovi.front.page.whyjoin.WhyJoinPage;

/**
 * Application object for your web application.
 */
public class WicketApplication extends WebApplication {

    @Override
    public Class<? extends WebPage> getHomePage() {
        return HomePage.class;
    }

    @Override
    public void init() {
        super.init();

        setSpringInjector();

        mountPage("potvrda-ok", RegisterMailSentPage.class);
        mountPage("potvrda", RegisterConfirmPage.class);
        mountPage("pocetna", HomePage.class);
        mountPage("registracija", RegisterPage.class);
        mountPage("zaboravljena-lozinka", ForgotPasswordPage.class);
        mountPage("lozinka-poslata", PasswordSentPage.class);
        mountPage("zasto-se-registrovati", WhyJoinPage.class);
        mountPage("dodaj-blogpost", AddBlogPostPage.class);
        mountPage("blog-post", BlogPostViewPage.class);
        mountPage("objavljeni", BlogPostListPage.class);
        mountPage("neodobreni", BlogPostListNotApprovedPage.class);
        mountPage("omiljeni", BlogPostFavsPage.class);
        mountPage("detalji", BlogPostViewPage.class);
        mountPage("blog", BlogPostListByBlogPage.class);
        mountPage("korisnici", PersonTopPage.class);
        mountPage("korisnik", PersonViewPage.class);
        mountPage("korisnik-izmena", PersonEditPage.class);
        mountPage("novi", NewLinksPage.class);
        mountPage("odprijatelja", FollowLinksPage.class);
        mountPage("podeljeno", BlogPostSharedPage.class);

        mountPage("nova-adresa", EmailConfirmPage.class);

        mountPage("picture-upload", UploadPhotoPage.class);
        mountPage("picture-chop", ChopPhotoPage.class);
    }

    protected void setSpringInjector() {
        getComponentInstantiationListeners().add(new SpringComponentInjector(this));
    }

    @Override
    public Session newSession(Request request, Response response) {
        return new BSession(request);
    }

}
